package cn.yxr.controller;

import cn.yxr.pojo.BackendUser;
import cn.yxr.service.BackendUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;


@Controller
@RequestMapping("/back")
public class BackendUserController {
    @Autowired
private BackendUserService backendUserService;
  // 登录
    @RequestMapping("/login")
    public String login() {
        return "backlogin";
    }
    @RequestMapping("/main")
    public String main(BackendUser user, Model model){
        user = backendUserService.login(user);
            model.addAttribute("name", user);
            return "main";
    }

    // 退出系统
    @RequestMapping("/out_login")
    public String out_login(HttpSession session){
        System.err.println("11");
        session.invalidate();
        return "backlogin";
    }
}
